//
// Created by 17775 on 2024/11/21.
//

#ifndef RAYCI_BEAM_LINE_H
#define RAYCI_BEAM_LINE_H

#include "RayCiPro_C.h"
#include <vector>
#include <QObject>
#include <windows.h>
#include <shellapi.h>
#include "../utils/PowerProfileData.h"

struct BeamLineDataBatch {
    std::vector<float> summedIntensity, summedIntensityValue;
    std::vector<float> center, centerValue;
    std::vector<float> width, widthValue;
    std::vector<float> peakIntensity, peakIntensityValue;
    std::vector<float> peakPosition, peakPositionValue;
    std::vector<float> YCrossPosition, YCrossIntensity;
};

struct BeamLineResult {
    int dCount = 0;
    double dPositionY = 0;
    double dPositionResidualY = 0;
    double dLineTilt = 0;
    double dLineCurvature = 0;
    double dWidth = 0;
    double dPositionUncertaintyY = 0;
    double dPositionResidualUncertaintyY = 0;
    double dLineTiltUncertainty = 0;
    double dLineCurvatureUncertainty = 0;
    double dWidthUncertainty = 0;
    double dLineLength = 0;
    double dHomogeneity = 0;
};

class Beam_Line : public QObject {
Q_OBJECT

signals:
    void getBeamLineDataS(const BeamLineDataBatch& data);

public slots:
    void exportReport();

public:
    int _iBeamLineDocId = 0;
    void stopBeamLine();
    void clearBeamLine();
    void setFrameSpan(int frames);
    void setTimeSpan(double dTime);
    void setSingleShot(bool bSingleShot) const;
    void getBeamLineData();
    std::shared_ptr<PowerProfileData<std::vector<float>>> getCrossSectionData();

    // Recording
    QString getRecordingRemark() const;

    // Analysis
    BeamLineResult getBeamLineResult(bool bUncertainty) const;

    // Sequence
    int getItemCount() const;
    QString getItemInfo(int index) const;
    void setCurrentItem(int index) const;

    // BeamLine
    void close(bool bWaitWhileClosing);
};


#endif //RAYCI_BEAM_LINE_H
